package gotype

import (
	"fmt"
	"time"
)

type Date time.Time

func (d Date) MarshalJSON() ([]byte,error){
	str := fmt.Sprintf("\"%s\"", time.Time(d).Format("2006-01-02"))
	return []byte(str),nil
}

func (d *Date) UnmarshalJSON(b []byte) error {
	t, err := time.Parse("\"2006-01-02\"",string(b))
	if err != nil{
		return err
	}
	*d = Date(t)
	return nil
}
